package com.hnust.service.impl;

import com.hnust.dao.TeacherClassDao;
import com.hnust.domain.ClassInformation;
import com.hnust.service.ClassService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("classService")
public class ClassServiceImpl implements ClassService {
    @Autowired
    private TeacherClassDao teacherClassDao;
    //根据老师id，考试id查询考试班级
    public List<ClassInformation> queryClassByTestIDTeaId(String tea_id, String testid){
        System.out.println("ClassServiceLpml"+teacherClassDao.queryClassByTestIDTeaId(tea_id,testid));
        return teacherClassDao.queryClassByTestIDTeaId(tea_id,testid);
    }

    //根据班级id查询专业名称
    public String queryMajorNameByClassId(String cla_id){
        return teacherClassDao.queryMajorNameByClassId(cla_id);
    }

//    根据班级名称查询班级id
    public String queryClassIdByClassName(String cla_name){


        int length = cla_name.length();
        String classgrade = cla_name.substring(0,4);
        String classnumber = cla_name.substring(length-2,length-1);
        String majorname = StringUtils.substringBetween(cla_name,classgrade,classnumber);
        //依次输出
        //班级名称，名称长度，年级，班号（不能超过个位数），专业名称
        System.out.println(cla_name);
        System.out.println(cla_name.length());
        System.out.println(classgrade);
        System.out.println(classnumber);
        System.out.println(majorname);
        return teacherClassDao.queryClassIdByClassName(classgrade,majorname,classnumber);
    }
}
